home *** CD-ROM | disk | FTP | other *** search
- Path: cypher.3do.com!user
- From: tsw@3do.com (Tom Watson)
- Newsgroups: comp.lang.c
- Subject: Re: can't get system calls to work vis c ver 1
- Date: Thu, 04 Apr 1996 13:20:34 -0800
- Organization: The 3DO Corporation
- Distribution: world
- Message-ID: <tsw-0404961320350001@cypher.3do.com>
- References: <828623397.22462@snowone.demon.co.uk>
- NNTP-Posting-Host: cypher.3do.com
-
- In article <828623397.22462@snowone.demon.co.uk>, merv@snowone.demon.co.uk
- (snowone) wrote:
-
- > Hi
- >
- > can anyone help me. I have msvc version one and i'm trying to get
- > this program working
- >
- > #include <process.h>
- >
- > void main()
- > {
- > system("dir");
- > }
- >
- > Will not compile. Says on linking _system is undeclared
- > (note at first would not compile until #undef _WINDOWS)
- >
- > have libraries oldnames, libw and mlibcewq
- >
- > This is driving me mad as it is such a simple program.
- >
-
- 1) The routine 'system' (as defined in the standard) lives in <stdlib.h>.
- 2) Main is not a 'void' routine.
- 3) As a result of #2, you need to supply a return value.
- That would make the program look like:
-
- #include <stdlib.h>
-
- int main (void)
- {
- return system("dir");
- }
-
- The 'void' as argument of main is because you don't use any arguments.
- This assumes that the "command processor" which the routine "system"
- invokes (it is system specific) understands the "dir" command. The
- "system" routine returns an 'int' which becomes the return value of 'main'
- back to the system, I hope this is acceptable.
-
- Now, if this is supposed to work under something like "Windows", and that
- environment needs special considerations, you are on your own!! I don't
- do "Windows".
-
- --
- Tom Watson
- tsw@3do.com (Home: tsw@johana.com)
-